<include file="public:header" />
<div class="allpagetop">网站设置<strong>/</strong>微信平台</div>
<div class="admin_main_nr_dbox">
  <div class="pagetit">
    <div class="ptit">微信平台</div>
    <div class="topnav">
      <include file="topnav" />
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
  </div>
  
     <div class="toptip">
    <div class="toptit">提示：</div>
    <p>如微信运营选择挂靠方式此处设置将会无效！（挂靠方式请参看公众号配置）</p>
    <p>据微信公众平台相关规定微信菜单最多设置3项，请合理安排！</p>
     
  </div>
  
  <form id="form1" name="form1" method="post" action="{:RU('Weixin/save_allmenu')}">
    <div class="admin_list_th">
      <div class="td1" style=" width:60%;"><div class="left_txt_td">菜单名称</div></div>
      <div class="td2" style=" width:10%;">排序</div>
      <div class="td2" style=" width:10%;">是否启用</div>
      <div class="td3" style=" width:20%;"><div class="admin_list_right">操作</div></div>
      <div class="clear"></div>
    </div>
    
    <volist name="list" id="list">
      <div class="admin_list_tr link_bk">
        <div class="td1" style=" width:60%;">
          <div class="category_img J_show" pid="{$list.id}"></div>
          <div class="category_input"><input name="id[]" type="hidden" value="{$list.id}" />
            <input name="name[]" type="text" class="input_text_default small" value="{$list.name}"/>
          </div>
          <div class="clear"></div>
        </div>
        <div class="td2" style=" width:10%;">
          <input name="sort[]" type="text" class="input_text_default small" value="{$list.sort}" style="width:50px;"/>
        </div>
        <div class="td2" style=" width:10%;">
          <eq name="list.status" value="1">
            <span style="color: #090;">已启用</span>
            <else />
            <span style="color: #999;">已禁用</span>
          </eq>
        </div>
        <div class="td3 edit" style=" width:20%;">
          <div class="admin_list_right link_blue">
            <a class="blue" href="{:RU('Weixin/menu_add',array('pid'=>$list['id']))}">此类下加子菜单</a>
            <a href="{$list.editurl}">修改</a>
            <a class="gray" href="{$list.delurl}" onclick="return confirm('删除大类会同时删除其子类，你确定要删除吗？')">删除</a>
          </div>
        </div>
        <div class="clear"></div>
      </div>
      
      <div class="J_cat_show"></div>
    </volist>
    
    
    <div id="J_add_show_div"></div>
    
    <div class="admin_list_foot">
      <div class="btnbox">
        <input type="submit" class="admin_submit"  id="ButSave"  value="保存菜单"/>
        <input type="button" class="admin_submit" id="ButADD" value="添加" onclick="window.location='{:RU('Weixin/menu_add')}'"/>
        <input type="button" class="admin_submit" id="ButSave" value="同步微信菜单" onclick="window.location='{:RU('Weixin/sync_mpmenu')}'"/>
      </div>
    </div>
  </form>

</div>
<include file="public:footer" />
<script type="text/javascript">
    $(document).ready(function(){

        function get_add_html()
        {
            var html='';
            html+="<div class=\"admin_list_tr link_bk\">";
            html+="<div class=\"td1\" style=\" width:60%;\">";
            html+="<div class=\"category_img\"></div>";
            html+="<div class=\"category_input\"><input name=\"add_pid[]\" type=\"hidden\" value=\"0\"/><input name=\"add_type[]\" type=\"hidden\" value=\"{$type}\"/>";
            html+="<input name=\"add_name[]\" type=\"text\"  class=\"input_text_default small\" />";
            html+="</div>";
            html+="<div class=\"clear\"></div>";
            html+="</div>";
            html+="<div class=\"td2\" style=\" width:20%;\">";
            html+="<input name=\"add_sort[]\" type=\"text\"  class=\"input_text_default small\" value=\"0\" style=\"width:50px;\"/>";
            html+="</div>";
            html+="<div class=\"td3\" style=\" width:20%;\">";
            html+="</div>";
            html+="<div class=\"clear\"></div>";
            html+="</div>";
            return html;
        }
        //添加顶级分类
        $("#J_menu_add").live('click',function()
        {
            html=get_add_html();
            $("#J_add_show_div").before(html);
        });
        
        //打开子菜单
        $(".J_show").click( function () {
            var infobox=$(this).parent().parent().next('.J_cat_show');
            if (infobox.html()=='')//第一次加载并且显示
            {
                pid=$(this).attr('pid');
                get_json_content(infobox,pid);
                $(this).toggleClass('show');
            }
            else
            {
                infobox.toggle();
                $(this).toggleClass('show');
            }
        });

        function get_json_content(infobox,pid)
        {
            html="";
            $.getJSON("{:RU('Weixin/menu_list')}", {pid:pid}, function(data){
                $.each(data.content, function(i, item) {
                    html+="<div class=\"admin_list_tr link_bk\">";
                    html+="<div class=\"td1\" style=\" width:60%;\">";
                    html+="<div class=\"category_sub_img\">&nbsp;</div>";
                    html+="<div class=\"category_input\"><input name=\"id[]\" type=\"hidden\"  value=\"" + item.id + "\"/>";
                    html+="<input name=\"name[]\" type=\"text\"  class=\"input_text_default small\" value=\"" + item.name + "\"/>";
                    html+="</div>";
                    html+="<div class=\"clear\"></div>";
                    html+="</div>";
                    html+="<div class=\"td2\" style=\" width:10%;\">";
                    html+="<input name=\"sort[]\" type=\"text\"  class=\"input_text_default small\" value=\"" + item.sort + "\" style=\"width:50px;\"/>";
                    html+="</div>";
                    html+="<div class=\"td2\" style=\" width:10%;\">";
                    if (item.status == '1') {
                        html+="<span style='color: #009900'>已启用</span>";
                    } else {
                        html+="<span style='color: #999999'>已禁用</span>";
                    }
                    html+="</div>";
                    html+="<div class=\"td3 edit\" style=\" width:20%;\">";
                    html+="<div class=\"admin_list_right link_blue\">";
                    html+="<a href=\""+ item.editurl +"\">修改</a>";
                    html+="<a class='gray' href=\""+ item.delurl +"\" onclick=\"return confirm('删除大类会同时删除其子类，你确定要删除吗？')\">删除</a>";
                    html+="</div>";
                    html+="</div>";
                    html+="<div class=\"clear\"></div>";
                    html+="</div>";
                });
                infobox.html(html);
                infobox.find(".category_sub_img").last().addClass('last');

            });
        }
    });
</script>
</body>
</html>